package com.xiang.sql.mapper;

import com.xiang.sql.entity.Stock;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * 库存 Mapper 接口
 * 
 * @author mac-xiang
 */
public interface StockMapper extends BaseMapper<Stock> {
  @Select({
      "SELECT a.*, b.name _group_name, c.name _goods_name, c.money _goods_money",
      "FROM `stock` a",
      "LEFT JOIN `group` b ON b.id = a.`gid`",
      "LEFT JOIN `goods` c ON c.id = a.`goods`",
      "${ew.customSqlSegment}"
  })
  List<Stock> selectList2(@Param("ew") Wrapper<Stock> queryWrapper);

  @Select({
      "SELECT COUNT(*) AS total FROM `stock` a",
      "${ew.customSqlSegment}"
  })
  Long count(@Param("ew") Wrapper<Stock> queryWrapper);

}